package com.lsl.abstract_factory.factory;

/**
 * 抽象工厂
 *
 * @author Zed
 * @description
 * @date 2022/11/27 18:14
 */
public abstract class Factory {
    public static Factory getFactory(String className) {
        Factory factory = null;
        try {
            factory = (Factory) Class.forName(className).newInstance();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            System.out.println(" 没有找到 " + className + " 类。 ");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return factory;
    }

    //抽象方法交给 Factory 类的子类实现
    public abstract Link createLink(String caption, String url);

    public abstract Tray createTray(String caption);


    public abstract Page createPage(String title, String authorName);

}
